home *** CD-ROM | disk | FTP | other *** search
- on getExtensionApp theExt
- if not stringp(theExt) then
- warning("getExtensionApp(): theExt not a string")
- return "Error: getExtensionApp(): theExt not a string"
- end if
- set dummyName to the pathName & "dummy." & theExt
- if fileExists(dummyName) then
- return insureShortFileName(locateExecutable(dummyName))
- end if
- if not objectp(factory("FileIO")) then
- if not fileExists(the pathName & "FileIO.DLL") then
- warning("getExtensionApp(): FileIO not available")
- return "Error: getExtensionApp(): can't locate FileIO.DLL"
- end if
- openXLib("FileIO.DLL")
- end if
- if not objectp(factory("FileIO")) then
- warning("getExtensionApp(): No FileIO factory.")
- return "Error: getExtensionApp(): no FileIO factory"
- end if
- set fioObject to fileio(mnew, "write", dummyName)
- if not objectp(fioObject) then
- warning("getExtensionApp(): FileIO(mNew, ''write''... failed")
- return "Error: getExtensionApp(): FileIO(mNew, ''write'' ... failed"
- end if
- fioObject(mWriteString, " ")
- fioObject(mdispose)
- set answer to insureShortFileName(locateExecutable(dummyName))
- set fioObject to fileio(mnew, "read", dummyName)
- if objectp(fioObject) then
- fioObject(mDelete)
- end if
- return answer
- end
-
- on insureShortFileName theFile
- global shortname, gVoid
- if not stringp(theFile) then
- warning("insureShortFileName(): theFile not a string")
- return gVoid
- end if
- if word 1 of theFile = "Error:" then
- return theFile
- end if
- set shortname to getShortFileName(theFile)
- if shortname = EMPTY then
- return theFile
- end if
- if word 1 of shortname = "Error:" then
- return theFile
- end if
- return shortname
- end
-
- on getNamedTasks theTaskName
- global gMasterAppObject
- insureMasterApp()
- set allTasks to getTaskIDs()
- if word 1 of allTasks = "Error:" then
- warning("getNamedTasks(): getTaskIDs() failed with '" & allTasks & "'")
- return []
- end if
- set nw to the number of words in allTasks
- if nw < 1 then
- warning("getNamedTasks(): mGetTaskIDs returned no tasks")
- return []
- end if
- set theTasks to []
- repeat with i = 1 to nw
- set thisTaskWord to word i of allTasks
- set thisTaskID to integer(thisTaskWord)
- if integerp(thisTaskID) then
- if taskName(thisTaskID) = theTaskName then
- add(theTasks, thisTaskID)
- end if
- end if
- end repeat
- return theTasks
- end
-
- on cancelAnyDialogs windowID
- if not integerp(windowID) then
- warning("cancelAnyDialogs(): windowID not an integer")
- return 0
- end if
- if not windowExists(windowID) then
- warning("cancelAnyDialogs(): window doesn't exist")
- return 0
- end if
- set motherTask to getWindowTask(windowID)
- set taskChildren to getTaskWindowIDs(motherTask)
- set nw to the number of words in taskChildren
- if nw < 1 then
- return 1
- end if
- repeat with i = 1 to nw
- set thisChild to integer(word i of taskChildren)
- if integerp(thisChild) then
- if windowHasChildren(thisChild) then
- set taskGrandchildren to getChildWindowIDs(thisChild)
- set nwg to the number of words in taskGrandchildren
- if nwg < 1 then
- next repeat
- end if
- repeat with k = 1 to nwg
- set thisGrandchild to integer(word k of taskGrandchildren)
- if integerp(thisGrandchild) then
- if not (windowName(thisGrandchild) = "Cancel") then
- next repeat
- end if
- if not (windowType(thisGrandchild) = "Button") then
- next repeat
- end if
- pressButton(thisGrandchild)
- end if
- end repeat
- end if
- end if
- end repeat
- return 1
- end
-
- on pressButton windowID
- if not integerp(windowID) then
- warning("pressButton(): windowID not an integer")
- return 0
- end if
- if not windowExists(windowID) then
- return 1
- end if
- set buttonRect to getWindowOutsideRect(windowID)
- set x to (integer(word 1 of buttonRect) + integer(word 3 of buttonRect)) / 2
- set y to (integer(word 2 of buttonRect) + integer(word 4 of buttonRect)) / 2
- set theTask to getWindowTask(windowID)
- fakeMouseClick(windowID, x, y)
- set giveUpTicks to the ticks + (5 * 60)
- repeat while the ticks < giveUpTicks
- if not windowExists(windowID) then
- return 1
- end if
- feedTimeSlice(theTask)
- feedGenericTimeSlice()
- end repeat
- return 0
- end
-
- on menuPress windowID
- if not integerp(windowID) then
- warning("menuPress(): windowID not an integer")
- return
- end if
- if not windowExists(windowID) then
- warning("menuPress(): windowID doesn't exists")
- return
- end if
- set theTask to getWindowTask(windowID)
- showMenu(windowID)
- feedTimeSlice(theTask)
- feedGenericTimeSlice()
- if the paramCount = 1 then
- return
- end if
- repeat with i = 2 to the paramCount
- if not stringp(param(i)) then
- warning("menuPress(): parameter " & string(i) & " not a string")
- return
- end if
- set nc to the number of chars in param(i)
- if nc <> 1 then
- warning("menuPress(): parameter " & string(i) & " not a 1-character string")
- return
- end if
- fakeCharacter(windowID, char 1 of param(i))
- feedTimeSlice(theTask)
- feedGenericTimeSlice()
- end repeat
- end
-
- on directorScoreWindow
- return unimp()
- end
-
- on unimp
- warning("unimplemented")
- end
-